<?php
   namespace app\mongodb\controller;
   use MongoDB\Driver\Manager;
  use MongoDB\Collection;
   class Index{
    protected $mongoManager;
  protected $mongoCollection;
  public function __construct()
  {
    $this->mongoManager = new Manager($this->getUri());
    $this->mongoCollection = new Collection($this->mongoManager, "mldn","dept");
  }
  public function test() {
    // 读取一条数据
    $data = $this->mongoCollection->findOne();
    print_r($data);
  }
  protected function getUri()
  {
    return getenv('2019127') ?: 'mongodb://127.0.0.1';
  }
   }
?>